package com.example.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;


/**
 * @author desire
 */
@Component
public class RoutingConfig {
    /**
     * 正常的队列
     */
    @Bean
    DirectExchange directExchange() {
        return new DirectExchange("directExchange");
    }

    @Bean
    Queue queue() {
        Map<String, Object> map = new HashMap<>();
        map.put("x-max-priority", 10);
        return new Queue("queue", true, false, false, map);
    }

    @Bean
    Binding binding(@Qualifier("directExchange") DirectExchange directExchange, @Qualifier("queue") Queue queue) {
        return BindingBuilder.bind(queue).to(directExchange).with("info");
    }
}
